package com.classicInterview;

/**
 * @Author: huangzhigao
 * @Date: 2023/5/8 20:16
 */
public class Code3 {
    public int lengthOfLongestSubstring(String s) {
        int maxLength = Integer.MIN_VALUE;
        int left = 0;
        int right = 0;
        char[] chars = new char[255];
        int length = s.length();
        while (right < length) {
            chars[s.charAt(right)]++;
            while (chars[s.charAt(right)] > 1) {
                chars[s.charAt(left)]--;
                left++;
            }
            maxLength = Math.max(maxLength, right - left + 1);
            right++;
        }
        return maxLength;
    }
}
